package com.umakr.ax.app.service;

import com.umakr.ax.common.mapper.WechatOpenAccountMapper;
import com.umakr.ax.common.model.WechatOpenAccount;
import com.umakr.ax.common.service.WechatOpenAccountService;
import com.umakr.ax.core.base.BaseService;
import org.jeewx.api.core.exception.WexinReqException;
import org.jeewx.api.third.JwThirdAPI;
import org.jeewx.api.third.model.ApiComponentToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * <p>
 * 第三方平台帐号信息 服务实现类
 * </p>
 *
 * @author Wmdz
 * @since 2018-01-09
 */
@Service
public class WechatOpenAccountWebService extends BaseService<WechatOpenAccountMapper, WechatOpenAccount>{

    @Autowired
    WechatOpenAccountService wechatOpenAccountService;


    public String getComponentAccesstoken(WechatOpenAccount wechatOpenAccount) throws WexinReqException {
        ApiComponentToken apiComponentToken = new ApiComponentToken();
        apiComponentToken.setComponent_appid(wechatOpenAccount.getAppid());
        apiComponentToken.setComponent_appsecret(wechatOpenAccount.getAppsecret());
        apiComponentToken.setComponent_verify_ticket(wechatOpenAccount.getTicket());
        String componentAccessToken = JwThirdAPI.getAccessToken(apiComponentToken);
        return componentAccessToken;
    }
}
